#include <cstdio>
#include <algorithm>

using namespace std;

int a[ 100001 ];

int main( )
{
    int n, m, i;
    while ( scanf("%d%d", &n, &m) )
    {
        if ( n == 0 && m == 0 ) break;
        for ( i = 0; i < n; i++ )
            scanf("%d", &a[ i ]);
        sort( a, a + n );
        printf("%d", a[ n - 1 ]);
        for ( i = n - 2; i >= n - m && i >= 0; i-- )
            printf(" %d", a[ i ]);
        puts("");
    }
    return 0;
}
